from share import *

import processor
import detoken
import machinecode

def compile(filename):
    with open(filename, "r") as f:
        r = f.read()
    codes = processor.tokenize(r)
    codes = detoken.detoken(codes)
    codes = machinecode.machinecode(codes)
    with open(get_filename(filename, "cys", "bin"), "wb") as f:
        f.write(codes)

def main():
    import sys
    compile(sys.argv[1])

if __name__ == '__main__':
    main()
